Imran reaches court to apologise to judge