Application of ordered codebooks to image coding