Handle unicode paths

This should fix #1381 . Many thanks to @LinneaWilling for finding the issue!