added checks on existence of imageIn and consistency check on imageIn being file or directory