Split imports into logical groups

This change set is result of running `goimports -w .` on the whole repository.
[It's considered a good practice](https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Imports) to separate stdlib imports from external imports.