Workaround problem where os.makedirs ignores the mode argument.