Download RedSn0w and the IPSW of the iOS you're trying to restore to (must match SHSH blobs). Open up RedSn0w, put your device into DFU mode. Go to Extras > Pwned DFU mode. Then go to Extras > Even More > Restore. Select IPSW and point it to the IPSW that you're trying to downgrade to and have the SHSH blobs for. Select remote and RedSn0w will retrieve your blobs. Then wait for RedSn0w to finish stitching the new IPSW and restore your iPhone back to it.
To jailbreak after restoring, open up RedSn0w, Extras > Select IPSW and point it to the iOS IPSW that your iPhone was restored to, which is the same as the one used before. Go back to the main screen, put your device into DFU mode. Make sure that RedSn0w recognizes it on this screen directly under Extras and above the Next> button. Select jailbreak and you should see a smaller window that would eventually say Patching Kernel. If it doesn't, you're doing something wrong. After the bit of loading, you'll be given a menu of 3-4 items that have check boxes next to them. If you're unlocking using UltraSn0w, tick Install Cydia and tick Deactivate. If you're just jailbreaking, just tick Install Cydia. Select Next and your iPhone should have a stream of white texts on it. The rest is automatic on your iPhone, do not unplug it until you're fully booted once again. If it's an iOS 6 jailbreak, you'll need to boot tether once you fully boot up after the jailbreaking process