public ByteArrayOutputStream compress(boolean noWrap, byte[] decompressedBytes) {
        ByteArrayOutputStream compressedBOS = new ByteArrayOutputStream();

       	byte [] tempBuffer = new byte[ 0x10000 ];

        int offset = 0;

    	while ( offset < decompressedBytes.length ) {

            Deflater deflater = new Deflater( 0, noWrap );

           	deflater.setInput( decompressedBytes, offset, decompressedBytes.length - offset );

           	deflater.finish();

            if ( deflater.needsInput() ) {
            	System.err.println( "needs input??" );
            }

            int nDeflated = deflater.deflate( tempBuffer );

            if ( nDeflated == 0 ) {
            	break;
            }

            compressedBOS.write( tempBuffer, 0, nDeflated );

            offset += deflater.getTotalIn();
    	}

        return compressedBOS;
	}
TODO make this more memory efficient!!
GPL/DMG/src/dmg/java/mobiledevices/dmg/zlib/ZLIB.java