1. A method comprising: receiving an image and a mask associated with the image; classifying blocks of at least one of a foreground layer and a background layer, wherein classifying blocks with three different classes comprises identifying each block that has only care pixels, each block that contains only don't care pixels, and each block that contains an edge created by at least one care pixel being adjacent to at least one don't care pixel; and performing a block-based, iterative multi-pass data filling process to fill a layer as part of compound document compression, wherein performing a block-based iterative multi-pass data filling process comprises, for each block during a first pass: filling each block in the layer classified as containing only care pixels with the pixel values of the corresponding block in the image; filling don't care pixels in each block classified as containing an edge with a value based on an average of care pixels in a window containing said each block, where the window is larger than the block size; and filling care pixels in each block classified as containing an edge with the pixel values of the corresponding pixels in the corresponding block in the image.