use tempfiles instead of locking

This avoids the issue of corrupted files being written to disk when some
renderer fails.