Fix encoding on tokens

Input is assumed to be UTF-8, so output is forced to be UTF-8 to
avoid it being interpreted as a binary string.