pymavlink: Fix warnings with global variables.

Global variable declarations within a function need to be done at the top, as
conditional statements do not introduce new scopes.
pymavlink: Move global variable declaration to the top and add comments.
pymavlink: Add comments for global variable.
pymavlink: Move scripting code to the top of mavutil.py.

Makes it easier to see what code is being executed when calling mavutil.
pymavlink: Spelling fix.
pymavlink: Fix broken mavutil.py.
pymavlink: Make timestamp usage more consistent in JSON output
pymavlink: avoid error is ardupilotmega dialect is not installed