I wouldn't bother with a "dmg" file.
Instead, just use a cloning app like CarbonCopyCloner or SuperDuper to create a cloned backup of the clean install onto another drive.
I did just this the day my late-2012 Mini arrived, so I'd have a "near-virgin" copy of the factory-installed software on another volume from which I could easily "begin again", if need be.
You could create this on another hard drive, or on a USB flash drive of suitable size, or perhaps even on an SDHC card.
Some important considerations:
1. I also put a copy of CarbonCopyCloner into the apps folder. Even though it didn't come from the factory that way, the "near-virginal clone" can replicate itself onto other drives, because CCC is already there.
2. I created an "empty" Administrative account, so the near-virginal clone could be booted "right to the finder" and ready-to-roll. Once other accounts are created or "migrated over", you can just delete the "empty administrator" account if you wish, or leave it around.
You should also be aware that if you use CCC, you don't have to worry about saving the recovery partition because CCC has the option to clone the RP along with the rest of the drive to the "target volume". What this means is that when you create the original "near-virginal clone", you are ALSO creating the recovery partition along with it.
And again, when it's time to replicate, the RP will get carried over, as well.
I have since used this setup successfully. A friend had a 2008-vintage iMac he needed to update from 10.5.8 to something more recent. So I did this:
1. Backed up his existing drive to an external using CCC
2. Connected my near-virginal clone, booted from it
3. Re-intialized his internal drive using Disk Utility
4. Used CCC to clone the contents of the near-virginal clone to his internal drive
5. Disconnected the near-virginal drive, booted from the "empty administrator" account (now on the iMac's internal drive)
6. Used Software Update to bring all software up-to-current
7. Re-connected his backup drive and used Migration Assistant to bring over his accounts, apps, data, and settings.
Worked great.
And it took surprising little time (the step-by-step process above makes it seem more involved than it actually -is- ...)