Great code for demonstrating the inner workings of JPEG using an easily interpreted language.
Minor critique - you may wish to include DPCM in your encoding of the DC components. Given how you're already segmenting DC and AC components, the modifications required to the encoder and decoder should be minimal.