Improve fixing file permissions.

So that it handles odd filenames better.