Implement the jpeg encoding branch (disabled still)