use img.format to determine img format instead of file extension
tests
Merge pull request #2 from vladozc/format-fix

Format fix