private void writeIDAT() throws IOException
	{
		IDATOutputStream ios = new IDATOutputStream(dataOutput, 8192);
		DeflaterOutputStream dos = new DeflaterOutputStream(ios,
				new Deflater(9));

		// Future work - don't convert entire image to a Raster It
		// might seem that you could just call image.getData() but
		// 'BufferedImage.subImage' doesn't appear to set the Width
		// and height properly of the Child Raster, so the Raster
		// you get back here appears larger than it should.
		// This solves that problem by bounding the raster to the
		// image's bounds...
		Raster ras = image.getData(new Rectangle(image.getMinX(), image
				.getMinY(), image.getWidth(), image.getHeight()));
		// System.out.println("Image: [" +
		//                    image.getMinY()  + ", " +
		//                    image.getMinX()  + ", " +
		//                    image.getWidth()  + ", " +
		//                    image.getHeight() + "]");
		// System.out.println("Ras: [" +
		//                    ras.getMinX()  + ", " +
		//                    ras.getMinY()  + ", " +
		//                    ras.getWidth()  + ", " +
		//                    ras.getHeight() + "]");

		if (skipAlpha)
		{
			int numBands = ras.getNumBands() - 1;
			int[] bandList = new int[numBands];
			for (int i = 0; i < numBands; i++)
			{
				bandList[i] = i;
			}
			ras = ras.createChild(0, 0, ras.getWidth(), ras.getHeight(), 0, 0,
					bandList);
		}

		if (interlace)
		{
			// Interlacing pass 1
			encodePass(dos, ras, 0, 0, 8, 8);
			// Interlacing pass 2
			encodePass(dos, ras, 4, 0, 8, 8);
			// Interlacing pass 3
			encodePass(dos, ras, 0, 4, 4, 8);
			// Interlacing pass 4
			encodePass(dos, ras, 2, 0, 4, 4);
			// Interlacing pass 5
			encodePass(dos, ras, 0, 2, 2, 4);
			// Interlacing pass 6
			encodePass(dos, ras, 1, 0, 2, 2);
			// Interlacing pass 7
			encodePass(dos, ras, 0, 1, 1, 2);
		}
		else
		{
			encodePass(dos, ras, 0, 0, 1, 1);
		}

		dos.finish();
		ios.flush();
	}