Catch possible exception for os.makedirs.

When 2 processes are creating the same dir, one of them will unnecessarily throw os.error exception.
Check whether dir exists before throwing the exception.