OP:
Instead of using "command-R" (recovery partition) at startup, try "command-OPTION-R" (internet recovery).
If you are connecting via wifi, you may need to enter your wifi password.
It will take some time for the OS Utilities to load (over wifi).
When you get to the Utilities menu, QUIT the OS installer and open Disk Utility.
In DU's window, select the topmost line that represents the ENTIRE DRIVE inside the iMac.
NOW try to erase it.
Does this go any better?
If so, now it's time to quit DU and re-open the OS installer and try again to do a fresh install.