Fix input consumption logic

This fixes a minor typo in the read_and_write function that tries
to force a BINARY encoding on strings.  It actually still worked
as it was, but this is better.

Also, this updates the function that trims the processed data off
the front of the input to use `byteslice` if that is available for
strings on the current Ruby.  This is really the only correct way
to deal with arbitrary UTF8 data.  If that isn't present, fall back
on the old way, but keep in mind that multibyte data will be
processed incorrectly.