write binary stream