Lossless compression of medical images