1. A method of generating a compressed representation of an image, the method comprising: receiving the image as a sequence of pixels in raster order; first encoding the sequence of pixels into first tokens based on a set of compression parameters while gathering statistical information about the first tokens, where the set of compression parameters includes token encoding parameters; analyzing the statistical information to determine whether a recompression of the first tokens will reduce an encoding size; and when recompression of the first tokens will reduce encoding size, second encoding the first tokens into second tokens based on the statistical information such that a number of bits used to represent the second tokens is less than a number of bits used to represent the first tokens.