fixing arithmetic coding