You cannot install anything past Snow Leopard on a 2007 iMac if you are selling it. You cannot sell OS X Lion or later. Only the new buyer can purchase and install it. You must install the original version of OS X that came with the computer on two software restore DVDs, or you can install the retail copy of Snow Leopard purchased from the Online store.
You can purchase Snow Leopard through the Apple Store:Mac OS X 10.6 Snow Leopard - Apple Store (U.S.). The price is $19.99 plus tax. You will be sent physical media by mail after placing your order.
After you install Snow Leopard you will have to download and install the Mac OS X 10.6.8 Update Combo v1.1 to update Snow Leopard to 10.6.8 and give you access to the App Store. Access to the App Store enables you to download Mavericks if your computer meets the requirements.
Before Selling or Giving Away Your Pre-Lion Mac
Follow these instructions until you get to Step 5:
What to do before selling or giving away your Mac - Apple Support
At Step 5 you will need a Snow Leopard DVD or the installer disc that came with the computer.
- Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came with your computer. Insert the disc into the optical drive and restart the computer. After the chime press and hold down the "C" key. Release the key when you see a small spinning gear appear below the dark gray Apple logo.
- After the installer loads select your language and click on the Continuebutton. When the menu bar appears select Disk Utility from the Utilities' menu. After Disk Utility loads select the hard drive entry from the left side list (un-dented entry - mfgr.'s ID and drive size.) Click on the Partition tab in the Disk Utility main window. Set the number of partitions to one (1) from the Partitions drop down menu, click on Options button and select GUID, click on OK, then set the format type to MacOS Extended (Journaled), then click on the Apply button.
- When the formatting has finished quit Disk Utility. Proceed with the OS X installation and follow the directions included with the installer.
- If you are planning to sell or give your computer away, then do the following: After you reformat your hard drive and reinstall OS X, the computer restarts to a Welcome screen and asks you to choose a country or region. If you want to leave the Mac in an out-of-box state, don't continue with the setup of your system. Instead, press Command-Q to shut down the Mac. When the new owner turns on the Mac, the Setup Assistant will guide them through the setup process.