Auto fix file permissions

Fixes #627