Declare the sizeHint field of avifIO as uint64_t

Since the sizeHint field of the avifIO struct may represent the size of
a file, it should be declared as uint64_t in order to support large
files (files larger than 2 GB). The current size_t type is 32 bits on
32-bit platforms.

Since the 'offset' parameter of the avifIO read() function is uint64_t,
sizeHint should be of the same type. In other words, file offset and
file size should have the same type. (I assume 'offset' is declared as
uint64_t in order to support large files.)

In avifIOCreateFileReader(), check for ftell() failure to avoid casting
-1 to an unsigned type (whether it's size_t or uint64_t).

Also declared the 'data' parameter of the avifIO write() function as a
const pointer.
diff --git a/src/io.c b/src/io.c
index fe0ad4c..32b7229 100644
--- a/src/io.c
+++ b/src/io.c
@@ -129,7 +129,11 @@
     }
 
     fseek(f, 0, SEEK_END);
-    size_t fileSize = (size_t)ftell(f);
+    long fileSize = ftell(f);
+    if (fileSize < 0) {
+        fclose(f);
+        return NULL;
+    }
     fseek(f, 0, SEEK_SET);
 
     avifIOFileReader * reader = avifAlloc(sizeof(avifIOFileReader));
@@ -137,7 +141,7 @@
     reader->f = f;
     reader->io.destroy = avifIOFileReaderDestroy;
     reader->io.read = avifIOFileReaderRead;
-    reader->io.sizeHint = fileSize;
+    reader->io.sizeHint = (uint64_t)fileSize;
     reader->io.persistent = AVIF_FALSE;
     avifRWDataRealloc(&reader->buffer, 1024);
     return (avifIO *)reader;
diff --git a/src/read.c b/src/read.c
index 6b07664..379a848 100644
--- a/src/read.c
+++ b/src/read.c
@@ -331,7 +331,7 @@
     avifFree(decodeInput);
 }
 
-static avifBool avifCodecDecodeInputGetSamples(avifCodecDecodeInput * decodeInput, avifSampleTable * sampleTable, size_t sizeHint)
+static avifBool avifCodecDecodeInputGetSamples(avifCodecDecodeInput * decodeInput, avifSampleTable * sampleTable, uint64_t sizeHint)
 {
     uint32_t sampleSizeIndex = 0;
     for (uint32_t chunkIndex = 0; chunkIndex < sampleTable->chunks.count; ++chunkIndex) {
@@ -371,7 +371,7 @@
             if (sampleSize > UINT64_MAX - sampleOffset) {
                 return AVIF_FALSE;
             }
-            if (sizeHint && ((sampleOffset + sampleSize) > (uint64_t)sizeHint)) {
+            if (sizeHint && ((sampleOffset + sampleSize) > sizeHint)) {
                 return AVIF_FALSE;
             }