JPEG output: enable optimized coding

Add OPTIMIZED=YES/NO/ARITHMETIC (default YES) format option to turn on optimized
Huffman coding.
If set to NO, use standard Huffman tables (a little bit faster in theory, but
less efficient for output size).
If set to ARITHMETIC, will use Arithmetic entropy coding instead of Huffman, for
smaller size. Note that Arithmetic coding/decoding is available in libjpeg-turbo
implementation, but not in IJG libjpeg-6b or later. So must only be used in
combinations with clients that are known to be able to decode Arithmetic encoded
JPEG.