Fixes ioctl return

  refine []byte construction
  print err before panic