Improved PNG parsing
Added unit tests for PNG parsing
Merge pull request #2377 from mucek4/PNG2

Improved PNG parsing 
Refactoring: limit code repetitions