bitmap.py: Rewrite for better clarity and to properly support img files

* Output file may now *optionally* be a .h or .img
* Added sanity check for when input == output
* Produces same output as previous bitmap.py