you can take step 3 before you start residency.
however, you can not apply for your license until you have completed your intern year. i.e. you can send in your application to the board on july 1, right after finishing internship.
you must, if NOT a foreign medical grad, apply before the beginning of your pgy 3 year (before the beginning of your 25th month of residency). if you ARE a foreign medical grad, that you need to apply for your license before the beginning of your pgy 4 year (before the beginning of your 37th month of residency).