Extract reading boilerplate into rstream.c module

This code was adapted from input.c and contains all the setup for reading from
a libuv stream with arbitrary buffer size.