Okay so the big problem is that when you upgrade to the latest and greatest firmware from apple it updates your baseband in your phone, if you then try and downgrade to a previous firmware (3.1.3 – IPSW file) it will give you a 1015 error and will be stuck in a recovery mode loop. I have posted the entire process below, and from this you should be able to restore your iPhone 3GS back to 3.1.3. – O