Convert contents to string before writing to temp file
Merge pull request #4914 from basepi/managedfix

Convert `contents` to string before writing to temp file