added arithmetic coding algorithm