AMHERST, N.Y. -- An Amherst doctor will serve two years in prison for illegally prescribing painkillers to feed both his own addiction, and that of others. 

Dr. Albert Cowie says he was grateful to be in court Thursday taking responsibility for his actions because so many people lose their battle with addiction. 

Cowie pleaded guilty last January to obtaining controlled substances through fraud and health care fraud.

Prosecutors say he wrote more than 250 illegal prescriptions for drugs like Percocet, oxycodone and hydrocodone between 2010 and 2014 while working as a radiologist.

They say he would give the prescriptions to other people, who had them filled, kept some of the drugs for themselves and gave the rest to Cowie. 

Investigators say there were about four other people involved. 

Cowie says he is now clean, and spends his time volunteering. He adds he is sharing his story as a cautionary tale to help others avoid going down the same path. 

Acting U.S. Attorney James Kennedy says he hopes that is true, and that this case is a reminder of the serious consequences of drug use.

"We're not going to go away, because lives are at stake. If you use these drugs, no matter who you are, you need to get help immediately. Because if you don't, you'll end up either dead or, if you're lucky, in jail," said Kennedy. 

The judge is allowing Cowie to voluntarily surrender to prison once he's given a time and location to do so.