Previously it treated d.pos as a character index and indexed into the string,
even though StringIO#getbyte treats d.pos as a byte index.
This makes getc work properly with getbyte (fixes #2282).
This also makes it much more efficient, since string indexing for
non-fixed-width encoded strings such as UTF-8 strings takes linear time