diff --git a/lib/functions/image.js b/lib/functions/image.js
index <HASH>..<HASH> 100644
--- a/lib/functions/image.js
+++ b/lib/functions/image.js
@@ -62,16 +62,18 @@ Image.prototype.close = function(){
 
 Image.prototype.type = function(){
   var type
-    , chunk = fs.readSync(this.fd, 10, 0)[0];
+    , buf = new Buffer(4);
+  
+  fs.readSync(this.fd, buf, 0, 4, 0);
 
   // GIF
-  if ('GIF' == chunk.slice(0, 3)) type = 'gif';
+  if (0x47 == buf[0] && 0x49 == buf[1] && 0x46 == buf[2]) type = 'gif';
 
   // PNG
-  if ('PNG' == chunk.slice(1, 4)) type = 'png';
+  else if (0x50 == buf[1] && 0x4E == buf[2] && 0x47 == buf[3]) type = 'png';
 
   // JPEG
-  if ('JFIF' == chunk.slice(6, 10)) type = 'jpeg';
+  else if (0xff == buf[0] && 0xd8 == buf[1]) type = 'jpeg';
 
   return type;
 };
Refactored Image#type()