How can I factory-restore a Samsung J5 (2015) SM-500FN? What I have:

I have a Samsung J5 (2015) SM-500FN which ran out of storage and basically hung itself up. There is no data I want to recover, but I want to install either a stock ROM or (preferably) something else like Lineage - I just want to get a usable phone again.

My problem:


I have tried to download many stock ROMs from reputable sources like SamMobile (for this specific phone, but trying different release dates and country codes) but every single one of those ZIPs is corrupt, even when downloading from a different computer. 
Flashing with ODIN anyway gives a FAIL result and a device that cannot boot, not even into recovery: It gives a green screen with the text: An error has occurred while updating the device software. Use the Emergency recovery function in the Smart Switch PC software.
Ironically, the Smart Switch software just says this device is not supported. The older Kies3 software lets me enter the exact model# followed by the serial# - but then it says this device is not supported. So neither Samsung software is usable, but I can still use ODIN.
Even with the phone in this broken state, I can install TWRP again. So it is not completely bricked. I boot into TWRP and copy a LineageOS ZIP file to /sdcard, but when I try to install that, the TRWP console says: E3004: This package is for device j5nlte,j5nltexx; this device is . Note it doesn't appear to recognize that this device is indeed the model j5nlte!
Android.SE says that "E3004" means my TWRP is too old, but I use twrp-3.1.1-1-j5nlte which is currently the newest version for this phone.
I would also like to try a factory reset, but that requires the stock recovery which won't boot (see step 2 above).


My question:  How do I get out of this catch-22?

It seems that if I could just get around that E3004 then I would be fine. But I have found no ways to trick the installer into ignoring that error.
A friendly forum user pointed me to this updated version of TWRP which I could install using the already installed TWRP. 

After upgrading the TWRP itself, I was then able to install the ROM I wanted. Problem solved!