Most Imacs suffer from faulty capacitors on the main board.
It's quite an involved job replacing them but not beyond anyone who is competent with tools and a soldering iron.
Replacing the capacitors will sole all the problems of break up of the display and freezes and locking up.
The capacitor kits can be obtained on ebay.
I have fully refurbished my own G5 imac and look forward to many extra years of use.
These computers also suffer from power supply failure which also involves replacement of capacitors.
Unfortunately for the world a company in Korea supplied the worlds electronics industry with duff capacitors.
Apple, Dell, Sony and many other well known manufacturers fell victim to the duff capacitors.
Good luck with repairing your G5 the component cost for a full set of Japanese Rubicon capacitors is approximately £20.
I would not choose the cheaper suppliers of capacitors because the are often the wrong size and you might be putting potentially duff capacitors back in your computer and it will fail again.