To avoid the passcode lock, you must hard reset your iPhone by holding down the lock button and the home button down simultaneously until the iPhone turns off.
'''Press and hold the home button while the iPhone is off''' and plug it into your Mac while still holding the home button down. The iPhone will turn on by itself when it is plugged it, but because you are holding the home button down, it will boot up in Recovery Mode.
iTunes will say "iTunes has detected an iPhone in Recovery Mode. You must restore it." It is now okay to release the home button.
Procede to restore your iPhone to factory settings, and then you may select a backup to restore it to after it has been erased.
Hope this helps! It's been a while since I've done it. Let me know if you need clarification on the steps. :)