If your iMac is running hot or running for extended periods of time I would first check to see if it is full of dust. If you are going that deep into the iMac and you have a compressor I would remove the glass, remove the aluminum front panel and then the LCD panel and take the compressor and blow out all the dust in the interior of the Mac with special attention to the fan(s) which will likely be caked in dust.
If your iMac looks very clean inside then I would consider the temperature sensor however in pretty much any older Mac and every computer I service I have almost always discovered that it is quite full of dust.
If you don't feel comfortable pulling the LCD you can try blowing dust out by shooting compressed air through the slot up top. I would not recommend using canned air, mainly because it is not powerful enough and second because you will wind up burning through a can trying to fix the problem and likely won't have enough pressure. Also not sure how much more environmentally friendly the new formulations are vs the ozone killing older stuff.
If you can't find a compressor handy, look for a shop, garage or auto body painter but try and find one that has a moisture trap on their system. Or just go to a place like Princess Auto or Harbour Freight and pick up a light duty one. They are also handy for pumping up car tires.
One word of caution when using a compressor, use it gently on the fan blades, too much force on older brittle blades can cause them to disintegrate.