Add utils for creating tempfile

These functions are useful for creating different
temporary files with specialized content. write_to_tempfile
is new function intead create_tempfiles in tests.utils module.

Blueprint: common-unit-tests
Change-Id: Ia51d416b2828a95fbb60d019cc92c4c8288bccc3