serialize and deserialize b-encode format into byte array