Convenience functions for encoding and decoding byte arrays