How to mount DMG's that fail

I had downloaded some DMG files to install some software and kept getting these error messages:
Unable to attach "******.dmg" - Device not configured.
 
It was happening for more than one .dmg file, and I'm sure the download was not corrupted.
 
At first, I tried using the Disk Utility, thinking it was related to disk permissions, but the option wasn't present when I selected the DMG. Clicking on "Verify disk" didn't help either, and resulted in the same error "Device not configured".
 
Tried the instructions below and they worked.
 
1. Highlight the following text and run in terminal
 
sudo kextunload -c com.apple.AppleDiskImageController
 
You will be asked for the admin password.
 
2. Copy and paste the following as your next command
 
sudo kextload -b com.apple.AppleDiskImageController
 
3. Now try to mount those .dmg files. Map