Code cleanup:

- moved all Etcd related code to lib/etcdctl.sh and update the main
  script to only use those functions;
- fixed a small issue when the cloned repository was removed after
  an image was build, in which case it should clone again and see if
  a build is necessary;
- simplified the urlencode() function to only use Bash builtins (it
  appears that xxd is not standard on all Linux systems).