Try using a lossless codec, e.g. HuffYUV or FFV1:
ffmpeg -i frame%04d.png -c:v huffyuv test.avi
ffmpeg -i frame%04d.png -c:v ffv1 -qscale:v 0 test.avi
Both codecs look portable. HuffYUV appears to be the more popular, but for some reason, huffyuv encoding seems broken on my system, and I get weird colors and black horizontal banding. It could have something to do with the input being RGB (from PNG) and not YUV (input from a raw YUV420 video file works OK). So here are some alternatives (not completely lossless, but visually quite good):
ffmpeg -i frame%04d.png -qscale:v 0 test.avi
ffmpeg -i frame%04d.png -c:v mjpeg -qscale:v 0 test.avi