sudo dd bs=1m if=source.img of=/dev/rdiskX
the key is to use rdisk instead of disk on output file name.
The last week I had some problem with the creation of a bootable usb dongle with kali linux. Here is the topic that help me to solve the problem
Inside your .DMG file you should have “Install OS X Mountain Lion” app, right click on it and press “Show package contents“, somewhere inside you should have “InstallESD.dmg” package. This is the package (not the image) that content image disk, be careful! The package named Mac OS X Install ESD is the right one that you have to copy in your key using disk utility