Please provide more information about the situation.
What kind of iMac is it? There were over 4 different designs of iMac through the years -- we really need to know exactly which one it is, as they were all basically different computers.
What version of OS X are you trying to install?
Where did those OS X install CDs/DVDs come from -- were they included with the computer when you bought it? Are they retail versions that you purchased in a box, from a store (either online or brick & mortar)? Are they disks you borrowed from someone, perhaps who owns a different model of Macintosh?
At what point in the install process do you see the error?