compress/decompress image to/from memory