Romo hurt, but Cowboys rally for OT win in San Francisco