CHICAGO (CBS) — A former state lawmaker dying of cancer and lung disease has been sentenced to 8 years in prison, for collecting and exchanging more than 2,700 images of child pornography, which his judge called a “despicable crime.”

U.S. District Judge Edmond Chang also ordered former state Rep. Keith Farnham to begin serving that prison term in two months, denying his attorneys request to allow him to stay on house arrest and die at home.

Farnham’s doctors have given him only four months to live. He has been diagnosed with bladder cancer, pulmonary fibrosis, and hepatitis. He breathes with the help of an oxygen mask.

Chang moved the sentencing hearing to a Kane County courtroom in Elgin, rather than the Dirksen Federal Courthouse in downtown Chicago, due to Farnham’s failing health.

Farnham resigned from the Illinois House last year, and later pleaded guilty to child pornography charges, admitting he had a collection of more than 2,700 videos and pictures of children being sexually abused. Some showed girls as young as two years old crying while they were victimized.

Chang said Farnham committed a “despicable crime” that created “a nightmare” for the children involved.

Farnham apologized for his crimes, and said he also was the victim of sexual abuse as a child.