Make internal string use encoding of the IO for Ruby >= 1.9