Optimized image painting