By defining preferred image quality, user creates two constant tables, one for luminance and one for chrominance. Those tables are saved in file header for later decompression. Every value in matrix is divided with right table constant and rounded to integer. This part is crucial one, considering we choose the quality of output picture. Lower frequencies coming first and higher last.
Higher ones are likely to be zeroes and overall compression is improved.
There are two encoding mechanisms in use today - Huffman or arithmetic. Huffman coding is explained in details in standard algorithm section. The difference in structure is a little one. Progressive JPEG additionally reorders the compressed data. Baseline JPEG, while decoding, draws line after line until all the image is shown.