avcodec encoder: get bytes per pixel from context if needed

Falling back to 3 bytes broke the buffer allocation for BMP with ffmpeg, which
defaults to RGBA.

Fixes #9687