WriteBitstream util