To possibly avoid any filename collisions, my humble suggestion is to maybe place disk images that are in the process of being created inside of the $TMPDIR
folder, and then add a custom, guid-like text string to the end of it.
For example:
$TMPDIR/MyDiskImage_dropdmgtemp-42a08354-c790-4a73-8274-965ec68c59fd.dmg
and if the filename is too long, truncate it (only for the temp file, though). For example, take a close look somewhat near the end of the filenames:
$TMPDIR/ccccccdssdftgsdfgsdfgdsfgdsfgdsfgdsfgdsfgdsfgdsfgdsgdsfggdfsdfggdfsdsgfgfdsdfgsdfgsdsgfgdsfgdfsccccccdssdftgsdfgsdfgdsfgdsfgdsfgdsfgdsfgdsfgdsfgdsgdsfggdfsdfggdfsdsgfgfdsdfgsdfgsdsgfgdsfgdfsdddddddddAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_dropdmgtemp-29c117b0-9ca9-43cb-a625-4614eecbff35.dmg
would get truncated to:
$TMPDIR/ccccccdssdftgsdfgsdfgdsfgdsfgdsfgdsfgdsfgdsfgdsfgdsgdsfggdfsdfggdfsdsgfgfdsdfgsdfgsdsgfgdsfgdfsccccccdssdftgsdfgsdfgdsfgdsfgdsfgdsfgdsfgdsfgdsfgdsgdsfggdfsdfggdfsdsgfgfdsdfgsdfgsdsgfgdsfgdfsdddddddddAaB_dropdmgtemp-29c117b0-9ca9-43cb-a625-4614eecbff35.dmg
Hope this makes sense and proves to be somewhat useful.