Update get_filename_safe_course_id to be more restrictive.

Instead of hardcoding knowledge about colons, just replace all
but a well-defined set of supported characters.

And fix a PEP8 violation.