A man asked, "Messenger of Allah, will we be held accountable for what we did in the days of ignorance?"He replied, "Whoever does well in Islam will not be held accountable for what he did in the days of ignorance, but whoever does evil in Islam will be held accountable for both the former and the latter."
قال رجل: يا رسول الله أنؤاخذ بما عملنا في الجاهلية؟ قال: من أحسن فى الإسلام لم يؤاخذ بما عمل في الجاهلية، ومن أساء في الإسلام أخذ بالأول والآخر.
Bukhari narrated it in the chapter on seeking the repentance of apostates (6921), and Muslim in the Book of Faith (120), both of them via Mansur and Amash, from Abu Waail, from Ibn Masud, who said, and then he related it. The wording given is Bukhari's, and Muslim's wording is similar.