Achraf Hakimi curled in a superb long-range free-kick as Morocco came from behind to beat Malawi 2-1 in the Africa Cup of Nations round of 16 fixture.