Write image functionality added