Speed up byte counting by using `stat()`

Using `stat()` is dramatically faster than scanning bytes one by
one. So, if we're being given a file, just `stat()` it. Otherwise
we can scan the bytes on STDIN.