"I read that if I get a new Mac computer I can use a FireWire thing to then put the 40k pics on a external drive, is that true?"
No.
New Macs
DO NOT HAVE firewire connectivity.
It's possible to connect an old firewire drive to a new Mac, but that involves buying two (not one, but TWO) adapters and try to rig up a solution that way (you don't really want to do that).
If the old iMac is "crashing due to no storage", then it's time to start DELETING stuff on the internal drive so it won't crash.
Also... THE MOST IMPORTANT THING YOU CAN DO:
MAKE A BACKUP of the internal drive on an EXTERNAL USB3 drive.
I would recommend that you download the appropriate version of CarbonCopyCloner and use that to clone the internal drive to your backup.
You can get CCC here (free to use for 30 days):
www.bombich.com
Don't delay on the backup.
If the computer completely quits, the only way to "get at" the internal drive will be to pry the iMac open and take the drive out. You could then buy a USB3/SATA dock to access it that way.
But if you have a backup -- things will go much easier.
Particularly in setting up the new Mac.