Generally, it samples the picture in 8x8pixel blocks, applies Discrete Cosine Transform to it, quantizes the DCT values(significant data reduction) and then encodes it into codewords.
Exact specifics should be available on the web if you are really interested.