Fix #346. Support for optimizers. Included jpegtran as example implementation.