Adding a few more hacks to make jpegoptiom work well.