KLV encoder and decoder in Python