The following is an excerpt from a sermon by John Piper on imputation:
...the experience of God's people through the centuries has shown what a treasure this truth (imputation) is in bringing people from the darkness of unbelief to the light of hope and joy in Christ. One example is John Bunyan, the writer of Pilgrim's Progress, who struggled terribly before he came to a settled faith in Christ. Here's what he wrote:
"One day as I was passing into the field . . . this sentence fell upon my soul. Thy righteousness is in heaven. And methought, withal, I saw with the eyes of my soul Jesus Christ at God's right hand; there, I say, was my righteousness; so that wherever I was, or whatever I was doing, God could not say of me, he wants [lacks] my righteousness, for that was just before [in front of] him. I also saw, moreover, that it was not my good frame of heart that made my righteousness better, nor yet my bad frame that made my righteousness worse, for my righteousness was Jesus Christ himself, "The same yesterday, today and, and forever" (Hebrews 13:8).
Now did my chains fall off my legs indeed. I was loosed from my afflictions and irons; my temptations also fled away; so that from that time those dreadful scriptures of God left off to trouble me; now went I also home rejoicing for the grace and love of God." (John Bunyan, Grace Abounding to the Chief of Sinners, [Hertfordshire: Evangelical Press, 1978, orig. 1666], pp. 90-91)