Added image writing