Purely functional implementation of JPEG and DECODER