correct file permissions and some encodings