How can our imperfect works be accepted by God?

10. Works acceptable only when sins have been pardoned

In this sense we shall concede not only a partial righteousness in works, as our adversaries themselves hold, but also that it is approved by God as if it were whole and perfect. But if we recall the foundation that supports it, every difficulty will be solved. A work begins to be acceptable only when it is undertaken with pardon. Now whence does this pardon arise, save that God contemplates us and our all in Christ? Therefore, as we ourselves, when we have been engrafted in Christ, are righteous in God’s sight because our iniquities are covered by Christ’s sinlessness, so our works are righteous and are thus regarded because whatever fault is otherwise in them is buried in Christ’s purity, and is not charged to our account. Accordingly, we can deservedly say that by faith alone not only we ourselves but our works as well are justified. 

John Calvin, Institutes of the Christian Religion, 3.17.10.