Renormalization of HQET Delta B=2 operators: O(a) improvement and 1/m matching with QCD