make encode more generic, assumes utf8 but falls back to iso-8859-1 if there is a problem