Implement flow-control on the output pipe.

Otherwise a slow reader on the output will cause internal stream buffers
to grow unbounded.

Note that the input pipe already has implicit flow-control via the
callback.