Fixed incorrect if logic stopping jpeg creation