change to tmp dir earlier to avoid leaving stuff behind