As per Linux standards, all temporary files should be generated in /tmp. There are functions for that (see mktemp).