Updating write_mpkg.py script to make robust

It's a little more robust...
Add dist command to make mpkg with permissions