main: Use g_mkdir_with_parents()

Instead of creating the parent directory by hand.
main: Create temp directories using g_mkdtemp()

Rather than creating the temp directory name by hand.