fix numImages paramter, also mkdir if doesn't exist