Model-based coding of images