Performance improvement: The code is now checking re-use of an already encoded image before actually encoding it. Before, the image was encoded in every case, but only really embedded the first time.