os.CreateTemp seems to perform the exactly same task here, and its
implementation seems having considered many more edge cases than the
implementation here. This patch uses os.CreateTemp here to avoid
reinventing the wheel.
Kubernetes-commit: de0f030bcec55944dcbf81a9eec4f4d87f76567f