Use "surrogateescape" error handler when encoding unicode paths.

On Python 3 functions like os.listdir() always returns unicode
paths. "invalid" byte paths are decoded using the "surrogateescape" error
handler which must also be used when decoding.
See os.fsencodefs() and os.fsdecode().