HELP! How To Downgrade from 4.1 to 3.1.3?

I accidently restored my iphone to 4.1 and the only way I can jailbreak it using "Spirit" is if I have it back to the version 3.1.3

How do I downgrade my iphone 3g? I've looked at many other websites nothing really helped, too confusing. Does anyone know any programs, etc? I have a mac btw if that helps too.
Actually now it's 4.0.2.
Download the firmware for this site:
Download All iPhone / iPod / iPad Apple Firmwares + iTunes + All Jailbreak tools - Mob2All

Original thread: https://forums.imore.com/threads/help-how-to-downgrade-from-4-1-to-3-1-3.196575/