Fix bug where tempfiles break if the S3 bucket subdirectory is more than one level deep