better use of tmpnam/mkstemp