I was having the same issue for a while with my old iMac (17" G5, no iSight). Mine was part of a batch that had an extended warranty to cover getting the logic board replaced, but even after getting that fixed, it still tended to overheat and shut down. I managed to fix it myself, but the solution isn't pretty, and is not for the faint of heart.
First off, I would suggest opening it up and blasting out all the dust that has been building up in there over the years, especially if it has never been cleaned before. Cans of compressed air work wonders, especially on tightly packed systems like iMacs and laptops. Make sure you blast out the CPU heat sink, easy enough from the bottom of the system.
If it keeps overheating after cleaning it, and the caps seem to be in good shape, you're welcome to try my solution if you aren't afraid to get your hands a little dirty...
I went out and picked up two 120mm(iirc) computer fans, cut two holes in the back panel of the iMac case directly on top of the cpu heat sink, and hooked up the fans so that the bottom one pushes air into the case, and the top one pulls air out. I tapped into the existing fan lines to get power, and used the connectors the fans came with so I can easily attach and detach the fans when opening the case. Cutting through the back of the iMac was a bit of a hack job, and as I said before, it isn't pretty to look at and it makes more noise than it used to, but I haven't had a single crash since doing it about 3 years ago. The system still gets used on a daily basis.
I snapped pictures of the process on my phone as I went, and would be willing to dig them up and post them if anyone is interested in giving it a shot and wants a bit more detail on how exactly I did it.