My implementation for the IMB decoder and encoder.