A man who spent nearly 50 years in prison for murder has been exonerated by a judge