http://www.usconstitution.net/constfaq_a4.html#Q64
Quoted from the above link:
A. The electoral process, at least for presidential elections, is spelled out in the Constitution in Article 2, Section 1 and the 12th Amendment.
Basically, each state has a number of electors equal to the number of senators and representatives they have in Congress (at least 3 per state).
On election day, the people of each state cast their ballot for the president and vice president. But what they are really doing is voting for a slate of electors pledged to those candidates. The fact that the people vote at all is a matter of tradition and/or state law rather than constitutional law. The electors in a state may be appointed any way a state sees fit. I don't think there is a single state that does not used popular ballot for that choosing, but they don't have to.
Once the votes have been counted, that candidate with the most votes gets all of the electors in that state. Electors may not be members of Congress or be in any other government position. The electors in the state meet and vote for the President and for the Vice President in separate ballots. Though the assumption is that the electors will vote for the chosen of their party, there is no constitutional rule that says that (in other words, a Clinton elector could have voted for Bush). Some states (Vermont, for example) have rules stipulating that electors will vote for the candidates of their party. The votes are transmitted to the Senate.
In the Senate, the votes are counted in the presence of the whole congress, and the President is the one with the majority of votes. If there is no majority, the top three candidates are voted upon by the assembled congress. Each state is given one vote, and the President is chosen by them; if no majority is found, votes continue. If no President has been chosen by the March 4th, the Vice President, who is chosen in a similar fashion, will be acting President.