handle encode errors and None return from getfilesystemencoding