The design of the 2009 and 2010 iMac 27s is that the back is used as a heat sink. The fans don't really remove heat from the heat sink. So what happens is the heat builds up on the back case during the day and it collects around the back of the iMac. What I've found is that a fan that blows some air on the back of the case helps to keep the internal fans spinning at base or near base levels.
Your fan control program should still run while the iMac is in Target Display Mode. When you come out of Target Display Mode, all of your programs should still be there. Does the fan control program not work in TDM?