Cuninghame, John, Lord Cuninghame; Scottish judge