In matters of faith, morals and teachings. He doesn't have to be perfect in his own personal life. Did Jesus pick men who were without sin as His Apostles?
Of course not, but His Twelve chosen ones never strayed from what He had personally taught them. The same with the Pope. He might err in his human behavior, but he CAN NOT err in the matters I listed above.
"In matters of faith, morals and teachings."
Teachings... hmmm... I can cite many a scripture in which there is contradiction.