Fix invalid byte sequence in UTF-8 for some source files

The encoding cannot be guaranteed in the file source read in from
IO.foreach.