<p>A method for losslessly encoding and compressing and decoding original, raw,raster data, and other files by optimizing the results of preprocessing and transformation techniques. Four stages are involved: pre-processing during which the data is replaced by predictive values and the deviations from the predictive value; mapping each block through a transform sequence using a lossy reversible mapping; minimizing the joint entropy of the transformed data and deviation by varying parameters for the predictive and transform step; and encoding the transformed sequence. At each stage of the compression of the data, different techniques are tried and compared and an optimal technique used to carry out that state.</p>