You can absolutely do that...there is some benefit to having matched pairs of RAM, but it is almost imperceptibly small for the iMac. It makes a bit more difference on machines with integrated graphics like the Mac mini and the MacBook.
I have an iMac with Intel GMA, pulled out 1 of the 256Mb sticks and replaced it with a 512Mb. I know there is benefit for having matched pairs in computers with integrated graphics but I haven't noticed any problems - and in any event the performance boost given in games etc. from the extra memory is worth it.