Refactoring Image class  method `convert_to_jpeg`