[cache] Fix writing to paths with unicode characters

* Use "compat_getenv"
* "write_json_file" now expects the filename to be a string
[test/test_compat] Restore the old value of the HOME environment variable

If the test was run before the YoutubeIE tests (for example by running
"nosetests -v test/test_compat.py test/test_download.py -m 'Youtube_1|compat_expand'"),
it wrote the signatures cache to the 'C:\Documents and Settings\тест\Application Data' folder.
It failed due to a problem in the cache code and the write_json_file function (fixed in f03e33b89a622af13fa5275c46b63aaa4814c499)