Fractal image compression is based on the self-similarity search of the image. The encoding process is computationally intensive. We present a fast fractal image encoding algorithm that is based on a refinement of the fractal code from an initial coarse level of a pyramid. Assuming that the distribution of the matching error is described by an independent, identically distributed (i.i.d.) Laplacian random process, we derive the threshold sequence for the objective function in each pyramidal level. The algorithm is quasi-optimal in terms of minimizing the mean square error. Computational efficiency depends on the depth of the pyramid and the search step size, and could be improved by up to two orders of magnitude over the computational effort required for a full search of the original image.