Stop crashing when trying to json encode closed tempfile params