add helper methods for encoding/decoding bitarrays