Maria Sharapova overcame an early scare before advancing to the quarter-finals of the WTA Sony Open in Miami.