finish 3870

specify encoding in `io.open` call (finishes #3870).