Hosts Brazil needed penalties and the agility of Julio Cesar, to squeeze past Chile into the quarter-finals of the World Cup.