private BufferedImage createRGBBufferedImage(ColorSpace cs, byte[] rgb, int width, int height)
{
// create a RGB color model
ColorModel cm = new ComponentColorModel(cs, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
// create the target raster
WritableRaster writeableRaster = cm.createCompatibleWritableRaster(width, height);
// get the data buffer of the raster
DataBufferByte buffer = (DataBufferByte)writeableRaster.getDataBuffer();
byte[] bufferData = buffer.getData();
// copy all the converted data to the raster buffer
System.arraycopy( rgb, 0,bufferData, 0,rgb.length );