I ran the AHT and it found nothing wrong with the
computer. I also ran the Disk Utility program and it
found no problems.
Do you think reinstalling OSX is the way to go?
Well, that will certainly tell you if the problem is software or hardware, but that would be a bit premature.
First, let me ask if your firmware is up-to-date? Your iMac's utility "System Profiler" in its "Hardware Overview" should be showing:
Boot ROM Version: IM41.0055.B08
SMC Version: 1.1f5
If you don't see the same reports, it probably needs one of these two updates:
http://docs.info.apple.com/article.html?artnum=303903
Your symptoms sound as if your iMac might not have the updated SMC firmware installed. According to Apple: "The SMC Firmware Update addresses boot issues with the iMac."
It's an extremely tiny update - takes about five seconds or less to download, but the installation requires caution, and strictly following the procedure will be necessary to avoid spending hours trying to correct any error you might make.
Remember, when you are quitting your open applications after downloading, but prior to installation - AirPort is an application and needs to be turned off. Only Finder and Dashboard should have a triangle next to their Dock icons during the installation of either of the firmware updates. You may very well have applications installed whose icons are not represented in the dock, so make sure everything gets quit prior to doing the install.
If your iMac happens to need both updates, it would be a mistake to try to do them at the same time. Once completed successfully, the update software packages can be deleted, as that's strictly a one time install - it's not software and can't be erased.
If the SMC firmware update is needed, after successful completion, you will need to
reset the SMC, which is not done as part of the installation.
If it turns out you do not need either update, you should perform a PRAM reset to see if that might resolve your problem. To reset the PRAM:
1. Shut down the computer.
2. Locate the following four keys on the keyboard: Command (Apple logo), option, P, and R. You will need to hold these four keys down simultaneously in step 4.
3. Start up the computer.
4. Press and hold the Command-option-P-R keys. You should press this key combination immediately after the startup chord sounds, and certainly before the gray screen's Apple logo appears.
5. Hold all four keys down until the computer restarts and you hear the startup chord for the second time. The PRAM reset will reset your sound level preference, so the second time may well sound more or less loud than the first.
6. Release the keys.
A second preference that's usually reset by this procedure is the Startup Disk preference. Let us know if you make any progress with your spontaneous shutdown problem.