IRF240 is a TO204 device, large metal can with ca. 1 square inch heat contact area with heatsink (through isolating washer).
IRF540 is a 220 device with about 1/4" contact area....
When the device is dissipating 100W for arguments sake, you will typically have at least 30 deg higher substrate temperature with the smaller device. Of course you could mount it on a large piece of copper to simulate a larger area, but you will be adding capacitance as well.
So, even though they appear to be similar, you are going to loose a lot more heat performance through the thermal washer. You will need more heatsinking for 540 than for 240, probably much more unless you use many parallel devices.
Have you considered using IRFP240 instead? This is a 247 device. IRFP244 works as well, and they are not all that expensive.
Petter