Encoding of image