Add methods for working with temporary files, and writing binary plists

These are two PRs in one because the second commit has a dependency on
the first.