Software Implementation of B-Format Encoding and Decoding