Create a directory before putting a file into it

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>