Pakistan court frees ex-PM Sharif for medical treatment