Connect the drive to your iMac. On the iMac go to Applications / Utilities / Disk Utility. Double click on Disk Utility. In the window that opens, in the left column you select the drive, and click on Erase. The drive should be formatted as Mac OS Extended (Journaled) to work best with your iMac.