backend_ps: Do not write to a temporary file unless using an external distiller

If `ps.usedistiller` is False, writes directly to the output file, instead of creating a temporary file and subsequently copying it to the output.

This is more efficient, and also works on restricted platforms such as Google App Engine, which are unable to provide a writable temporary file system.

Partial fix for Issue #1823.