WritableRaster raster=image.getRaster();
DataBufferByte buffer=(DataBufferByte)raster.getDataBuffer();
byte[] imgdata=(byte[])buffer.getData();
BitSwapOutputStream bsos = new BitSwapOutputStream(baos);
ModHuffmanOutputStream mhos = new ModModREADOutputStream(bsos,width);
RLEBit1OutputStream rlos = new RLEBit1OutputStream(mhos);
int len=width>>3; // eight pixel per byte
int end=8-(width&0x07); // how many bits of last byte represent image data