added method to convert bitfield into byte array