Fixes #299 - run_task api wasn't returning a response object in 'text' mode.

Also fixed mixed tabs and spaces in api.py
Merge branch 'bug/299'