Fixes to the encoder to support visual studio. Changes suggested by @r-lyeh and @anthrotype. - Use a portable simple PRNG instead of rand_r() - add missing <assert.h> include - disambiguate log2() argument type - remove endian.h include from write_bits.h