Yosemite hdiutil: create failed - error -5341

I had the same error -5341 and was able to work around it with the -megabytes option as suggested here.

hdiutil create -megabytes 130 Reassembly.dmg -srcfolder Reassembly

In this case the Reassembly directory is 107M and the resulting Reassembly.dmg is 97M. The -size 130m option did not work for me. My issue was intermittent - adding or removing one or two files would fix it or break it.