PEP8 fixes and other minor fixes.
prioritize jpeg over other