Refactored Update_Image function

Fixed some bugs related to attaching images when overwrite is set to on. Looks like everything works now.