President Luiz Inacio Lula da Silva and Senator Flavio Bolsonaro have voted in a tightly contested election.