public BufferedImage toImage()
    {
        BufferedImage output = new BufferedImage(this.width, this.height, BufferedImage.TYPE_3BYTE_BGR);

        WritableRaster raster = output.getRaster();
        DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
        byte[] pixels = buffer.getData();
        int index = 0;
        for(int y=0;y<this.height;y++)
        {
            for(int x=0;x<this.width;x++)
            {
                int v = (short)(this.get(y, x) & 0xFFFF);
                byte bv = (byte)((v > 0xFF) ? 0xFF : v);
                pixels[index] = bv;
                pixels[index+1] = bv;
                pixels[index+2] = bv;
                index += 3;
            }
        }

        return output;
    }