Modified internal code to avoid using bs_get_byte().

Some internal functions (listed below) were calling bs_get_byte to read
the byte stream. This might lead to a speed penalty: there's no reason that
internal code can't just access the stream directly.

Functions modified:
 - bs_save_string
 - bs_save_hex
Added sensible assertions before trying to use the stream.

The bs_malloc helper function contained a couple of assertions that the stream
being used seems to be sane. This commit defines those assertions as a macro
in bs_alloc.h and scatters that macro in the following functions:

 - bs_zero
 - bs_get_byte
 - bs_set_byte
 - bs_save_string
 - bs_save_binary
 - bs_save_hex

... thereby ensuring that the stream is OK before we try and use it.
Modified bs_malloc_output to null-terminate buffer.

bs_malloc_output is used to allocate memory for outputting data. This data is
most often string data which needs to be null terminated, and it's a pain for
individual save functions to have to:
 - remember to add the null
 - mess around with the length parameter to return the right thing

This commit changes the semantics of bs_malloc_output(). It now allocates a
buffer one byte larger than required, and writes a null terminator into that
extra byte.

String output works easily - allocate the number of bytes needed and the null
will silently be added with no extra work. The correct string length
is returned.

Binary output isn't affected either - adding an extra null doesn't make any
difference as the correct number of bytes is returned.
Added cast to shut up compiler warnings in tests/bs_alloc.c