Using tmpnam on Windows and mkstep on others so the compiler won't
complain about security.
Replaced mkstep and tmpnam by g_build_filename.
Removed redundant headers.