Create and clean up temporary directories