Fix viewing gallery with non-ASCII symbols in directory name

This commit fix bug when viewing gallery with non-ASCII symbols in directory name. In this case some browsers (Safari, in my case) redirect user to wrong (nonexistent) path.

Example: «Свадьба» converts to «C204L10» in location.hash.