Save as temporary file before bg rendering
Fixed several bugs from old code