Fixed bug with buffers overflowing on the final byte.