lib: handle partial sequences in streaming mode

Don't throw an EINVAL error when the chunk ends in a partial character
sequence. Store the remainder and prepend it to the next chunk.

Fixes #73.