static final ImageData convertMask(ImageData mask) {
		if (mask.depth == 1)
			return mask;
		PaletteData palette = new PaletteData(new RGB[] { new RGB(0, 0, 0),
				new RGB(255, 255, 255) });
		ImageData newMask = new ImageData(mask.width, mask.height, 1, palette);
		/* Find index of black in mask palette */
		int blackIndex = 0;
		RGB[] rgbs = mask.getRGBs();
		if (rgbs != null) {
			while (blackIndex < rgbs.length) {
				if (rgbs[blackIndex].equals(palette.colors[0]))
					break;
				blackIndex++;
			}
		}
		int[] pixels = new int[mask.width];
		for (int y = 0; y < mask.height; y++) {
			mask.getPixels(0, y, mask.width, pixels, 0);
			for (int i = 0; i < pixels.length; i++) {
				if (pixels[i] == blackIndex) {
					pixels[i] = 0;
				} else {
					pixels[i] = 1;
				}
			}
			newMask.setPixels(0, y, mask.width, pixels, 0);
		}
		return newMask;
	}