Imran Khan granted bail, leaves high court amid tight security