Missing file from previous commit
More work on stream functions
 - hardened against NULL pointers
 - bs_stream copes with zero data being sent
 - allowed bs_stream_empty to be called with NULL data and length in order to
   empty the stream queue without saving it
 - bs_stream_flush now copes with memory errors

Fixes gh-2