improve _File.write: support encoding option