create a DMG file on the command line
Sometimes you might not want to fiddle with the Disk Utility.
Instead, you can do it on the command line.
1. Open Terminal.app
2. Run this:
hdiutil create -encryption -size 2m -fs HFS+ -volname DISKNAME ~john/DISKNAME.dmg
This will create a 2 megabyte sized disk image, in HFS+ format, encrypted. It will ask for a password.
3. You can also convert formats, e.g. ISO to IMG
hdiutil convert -format UDRW -o raspbian.iso raspbian.img