How about using compare from the ImageMagic software-suite (http://www.imagemagick.org). Available for mac and all modern Linux distributions.
I'm not that familiar with comparing images, but I tried creating some samples and ran following snippets,
$ compare -identify -metric MAE same1.png same2.png null
>> same1.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.009
>> same2.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.000
>> 0 (0)
$ compare -identify -metric MAE same1.png diff.png null
>> same1.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.020
>> diff.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 6.01KB 0.000u 0:00.009
>> 209.225 (0.00319257)
And it seems to work as expected.
Hope that helps!
Edit, good point by DigitalTrauma, comparing between different formats/compression algorithms may be a problem,
$ compare -identify -metric MAE same1.png same2.xcf null
>> same1.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.080u 0:00.040
>> same2.xcf[0] XCF 640x400 640x400+0+0 8-bit DirectClass 2.73KB 0.070u 0:00.030
>> 0 (0)
$ compare -identify -metric MAE same1.png same2.bmp null
>> same1.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.010
>> same2.bmp[0] BMP 640x400 640x400+0+0 8-bit DirectClass 768KB 0.000u 0:00.000
>> 0 (0)
$ compare -identify -metric MAE same1.png same2.jpg null
>> same1.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.019
>> same2.jpg[0] JPEG 640x400 640x400+0+0 8-bit DirectClass 3.65KB 0.000u 0:00.009
>> 0.196766 (3.00245e-06)
So, when comparing against jpeg we get a difference, even though the pictures "look" the same. This is definitly not my area, but I don't think converting the pictures to the same format would make any difference since the compression (or whatever makes the pictures different) already is applied to the image.
$ convert same2.jpg same2-from-jpg.png
$ compare -identify -metric MAE same2.png same2-from-jpg.png null
>> same2.png[0] PNG 640x400 640x400+0+0 8-bit PseudoClass 256c 1.38KB 0.040u 0:00.020
>> same2-from-jpg.png[0] PNG 640x400 640x400+0+0 8-bit DirectClass 1.64KB 0.010u 0:00.000
>> 0.196766 (3.00245e-06)
Above we convert the jpg back to png and then compare it with the original, and it still differs.
Anyway, maybe this will give you some insight. I can definitely recommend ImageMagick when working with pictures.