PNG: remove duplicated code + gofmt