fix signed/unsigned comparison warnings in task.cc

Otherwise we get warnings on the Travis CI builds.