What does Kant mean by a Good Will

What does Kant mean by a Good Will and how does he argue that it is a good will, rather than the consequences of an action that determine the ethical worth of an action? How does Kant get from acting out of a good will to the categorical imperative and treating people as ends in themselves, as the basis for moral decisions.