Production and elliptic flow of heavy quarks at RHIC and LHC within a partonic transport model