Check for target directories on write and create recursively if they do not exist.