An Optimization Algorithm for Fractal Encoding of Graytone 2D Images