A method of compressing an image formed of pixels. The method includes providing a pixel of the image, to be encoded, selecting at least two pixels of the image, other than the encoded pixel, defining a straight line including the encoded pixel, to serve as prediction pixels, calculating a prediction value for the encoded pixel using at least the selected pixels, determining a difference between the calculated prediction value and the actual value of the encoded pixel, encoding the determined difference, such that the encoding error is bounded; and repeating for at least 5% of the pixels of the image.