The fully adaptive prediction error coder (FAPEC) is an entropy coder that typically offers better results than the adaptive Rice compressor. It uses basic preprocessing stages such as delta preprocessing, but it can also be combined with a discrete wavelet transform. We describe a new algorithm called hierarchical pixel averaging (HPA). It divides an image into blocks of , which are subsequently divided into smaller blocks, up to the basic level where one block corresponds to one pixel. Average pixel values are determined for each level from which differential coefficients are extracted. HPA allows the introduction of controlled losses with several quality levels, also allowing to progressively decompress a given image from lower to higher quality. It achieves better resolution in sharp image edges when compared to other lossy algorithms. HPA is based on simple arithmetic operations, allowing a very simple (thus quick) implementation. It does not use any floating-point operations, which is an interesting feature for satellite or embedded data compression. We present a first implementation of HPA and the results obtained on a variety of images, both for the lossless and lossy cases with different quality levels. Our results indicate that HPA + FAPEC offer a performance comparable to that of CCSDS 122.0.