The ImageIO JPEG encoder produces incorrect results for BufferedImages containing an alpha channel. The attached test shows the error. Run with "java JpegTest foo.jpg" e.g. on Windows and view the expected output. Then run with "java JpegTest -alpha foo2.jpg" and view the incorrect results. On Windows, Microsoft's default Picture Viewer will simply misinterpret the presence of the alpha channel and treat it as a color channel. On e.g. Solaris, xv won't open the resulting JPEG file.
It seems that the JPEG encoder used by ImageIO should either refuse to write images containing an alpha channel, or first discard the alpha channel if the file format can not handle it correctly.