Fixed file permissions being lost on OSX and Linux platforms