title: ImageIO not able to write a JPEG file
body: <p>I have a BufferedImage I'm trying to write to a jpeg file, but my Java program throws an exception. I'm able to successfully save the same buffer to a gif and png. I've tried looking around on Google for solutions, but to no avail.</p>
  
  <p>Code:</p>
  
  <pre><code>   File outputfile = new File("tiles/" + row + ":" + col + ".jpg");
     try {
         ImageIO.write(mapBufferTiles[row][col], "jpg", outputfile);
     } catch (IOException e) {
          outputfile.delete();
          throw new RuntimeException(e);
     }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code> Exception in thread "main" java.lang.RuntimeException: javax.imageio.IIOException: Invalid argument to native writeImage
   at MapServer.initMapBuffer(MapServer.java:90)
   at MapServer.&lt;init&gt;(MapServer.java:24)
   at MapServer.main(MapServer.java:118)
   Caused by: javax.imageio.IIOException: Invalid argument to native writeImage
   at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native Method)
   at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeOnThread(JPEGImageWriter.java:1055)
   at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:357)
   at javax.imageio.ImageWriter.write(ImageWriter.java:615)
   at javax.imageio.ImageIO.doWrite(ImageIO.java:1602)
   at javax.imageio.ImageIO.write(ImageIO.java:1526)
   at MapServer.initMapBuffer(MapServer.java:87)
   ... 2 more
  </code></pre>