improved reading/writing pathnames; fixed a mistyped function call writing strings in UTF-8 format (not used by default)