Extracted getEngines() logic.
Added --optimize flag.
Added basic support for jpeg optimization.