Replace the when promise library with bluebird.

Closes #968
Merge pull request #3826 from jaswilli/bluebird

Replace when with bluebird